import axios from 'axios'
import Vue from 'vue'
// import router from '../router'
const url = {
  services: 'http://81.70.155.101:8060/',
  local: 'http://192.168.240.216:8060/',
  xueming: 'http://192.168.43.156:8060'
}
const service = axios.create({
  baseURL: url.services,
  timeout: 2000000
})

// // 请求拦截
service.interceptors.request.use(config => {
  // if (router.history.current.fullPath === '/login') { return config } else {
  // console.log(role)
  config.headers.token = JSON.parse(sessionStorage.getItem('Token'))
  // config.headers.token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjY0MmFjYmI0YWIzMmJkMjJiZDllMjBhMyIsImFjY291bnQiOiJhZG1pbiIsInBhc3N3b3JkIjoiJDJhJDEwJHVDRm1tTml3RTlkSFhLbVFkeXUvSnVLY0l1SkY4ZzJLN3hQa2dHdGgyc01aREs0VC5EZ1ZxIiwibmFtZSI6Iui2hee6p-euoeeQhuWRmCIsIkF2YXRhclVybCI6IiIsInNleCI6IueUtyIsInBob25lIjoiMTU5MzIwMTMwNDAiLCJzYWx0IjoiNzYwMzE0Mjc1ODE0NzE5MDMxIiwicm9sZUlkIjoiNjIwZjA1NDA4NzUyMjRmNjQ0NzhkMDZiIiwib3BlbklkIjoiIn0sImlzcyI6InNkbCIsIm5iZiI6MTcwOTM0NjY0Nn0.X4zAGHRCgnkmTUDD0f7vwM-kJCZ9w0V2gML2qvOXwrY'
  // }
  return config
}, err => {
  return Promise.reject(err)
})

// 响应拦截
service.interceptors.response.use(res => {
  return res
}, err => {
  return Promise.reject(err)
})

export default service

Vue.prototype.$axios = axios
